import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import redis.clients.jedis.Jedis;
import redis.clients.jedis.JedisPool;

/**
 * @author xq
 * @version 1.0
 * @date 2021/4/28 13:23
 * @description 测试Spring整合redis连接
 */
public class TestSpringRedis {
    public static void main(String[] args) {
        ApplicationContext ac = new ClassPathXmlApplicationContext("classpath:application-*");
        // 获取数据源
        JedisPool jedisPool = ac.getBean(JedisPool.class);
        // 操作redis
        Jedis jedis = jedisPool.getResource();
        jedis.set("spring_redis_key","test");
        System.out.println(jedis.get("spring_redis_key"));
    }
}
